import request from '@/utils/request';

export const getArticleByIdAPI = (channel_id: number, timestamp = Date.now()) => {
  return request({
    url: '/v1_0/articles',
    params: {
      channel_id,
      timestamp,
    },
  });
};

export const getArticleDetailByIdAPI = (id: string) => {
  return request({
    url: '/v1_0/articles/' + id,
  });
};

export const likeArticleAPI = (target: string) => {
  return request({
    url: '/v1_0/article/likings',
    method: 'post',
    data: {
      target,
    },
  });
};

export const disLikeArticleAPI = (target: string) => {
  return request({
    url: '/v1_0/article/likings/' + target,
    method: 'delete',
  });
};

export const collectArticleAPI = (target: string) => {
  return request({
    url: '/v1_0/article/collections',
    method: 'post',
    data: {
      target,
    },
  });
};

export const disCollectArticleAPI = (target: string) => {
  return request({
    url: '/v1_0/article/collections/' + target,
    method: 'delete',
  });
};

export const followAPI = (target: string) => {
  return request({
    url: '/v1_0/user/followings',
    method: 'post',
    data: {
      target,
    },
  });
};

// 1. 封装API
export const disfollowAPI = (target: string) => {
  return request({
    url: '/v1_0/user/followings/' + target,
    method: 'delete',
  });
};

//
